package pl.ptemich.eav.engine.physics.impl;

import pl.ptemich.eav.engine.Point;
import pl.ptemich.eav.engine.physics.ColissionAlgorithmStrategy;
import pl.ptemich.eav.engine.physics.CollisionShape;
import pl.ptemich.eav.engine.physics.ShapeParameters;
import pl.ptemich.eav.engine.physics.StaticObject;



public class StaticObjectImpl implements CollisionShape, StaticObject {

  private Point worldPosition;

  private float marginX;
  
  private float marginY;  
  
  private ShapeParameters shapeParemeters;
  
  public StaticObjectImpl(Point worldPosition, float marginX, float marginY, ShapeParameters shapeParemeters) {
    this.worldPosition = worldPosition;
    this.marginX = marginX;
    this.marginY = marginY;
    this.shapeParemeters = shapeParemeters;
  }

  @Override
  public Point getWorldPosition() {
    return worldPosition;
  }
  
  @Override
  public void setWorldPosition(Point worldPosition) {
    this.worldPosition = worldPosition;
  }
  
  @Override
  public float getMarginX() {
    return marginX;
  }  
  
  @Override
  public float getMarginY() {
    return marginY;
  }    
  
  @Override
  public float getBoxL() {
    return worldPosition.getPosX() - getMarginX();
  }
  
  @Override
  public float getBoxR() {
    return worldPosition.getPosX() + getMarginX();
  }  

  @Override
  public float getBoxU() {
    return worldPosition.getPosY() + getMarginY();
  }
  
  @Override
  public float getBoxD() {
    return worldPosition.getPosY() - getMarginY();
  }   
  
  @Override
  public boolean checkCollision(StaticObject obstacle) {
    return ColissionAlgorithmStrategy.checkCollision(this, obstacle);
  }

  @Override
  public ShapeParameters getShapeParameters() {
    return shapeParemeters;
  }

}
